//
//  ImageAsset.h
//  OntheRoadV4
//
//  Created by ZhangYanhua on 14/12/1.
//  Copyright (c) 2014年 EricHuang. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AssetsLibrary/AssetsLibrary.h>
#import <Photos/Photos.h>
#import "DownscalingProtol.h"

typedef void(^FetchedImageHandler)(UIImage *result, NSDictionary *info);
typedef void(^FetchedVideoHandler)(AVAsset *result, NSDictionary *info);

@interface ImageAsset : NSObject
@property (nonatomic, strong) id<DownscalingProtol>   asset;    //需要遵循协议（可能为ALAsset和PHAsset,IOS8以上为PHAsset）
@property (nonatomic, strong) NSDate    *assetDate; //创建日期
@property (nonatomic, strong) id  assetIdentifier; //ALAsset为URL（应为NSURL类型） PHAsset为localIdentifier（NSString*）类型
@property (nonatomic, assign) double    duration; //时长
@property (nonatomic, strong) NSString  *groupIdentifier;
@property (nonatomic, strong) NSString  *durationString;
@property (nonatomic, assign) NSInteger index;

@property (nonatomic, assign) BOOL isPhoto; //是否是相片

//@property (nonatomic, strong) NSDateComponents *dateComp;
+ (void)deletedAssetsOfArray:(NSMutableArray *)array inGroup:(NSString *)groupIdentifier;

- (id)initWithALAsset:(ALAsset *)asset;

- (id)initWithPHFetchResult:(PHFetchResult *)assetsFetchResult
                    isPhoto:(BOOL)isPhoto
                 assetIndex:(NSInteger)index;

- (BOOL)isInTheSameSectionWithAsset:(ImageAsset *)imgAsset
              tenDaysAfterFirstDate:(NSDate *)tenDaysDate;

// 获取图片属性
- (void)getFullScreenImageWithBlock:(FetchedImageHandler)handler;

/**
 *  获取固定size的Thumbnail Image
 *
 *  @param size    size
 *  @param handler 获取成功的处理
 */
- (void)getThumbnailImageWithSize:(CGSize)size resultHandler:(FetchedImageHandler)handler;

/**
 *  获取视频文件的信息及资料
 *
 *  @param handler 获取之后调用的handler
 */
- (void)getVideoAssetWithBlock:(FetchedVideoHandler)handler;

@end